package indi.h.filefilter.utils;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;


public class StrFormat {
	private final static Logger l = Logger.getLogger(StrFormat.class);
	private final static String[] punctuation = { "\\.", ",", ":", ";", "。", "，", "：", "；" };
	private final static String[] brackets = { "\\(", "\\)", "\\[", "\\]", "\\{", "\\}", "<", ">", "\"", "\"", "（", "）",
			"【", "】", "｛", "｝", "《", "》", "“", "”" };
	private final static String[] specialSymbol = { "\\\\", "\\|", "/", "\\?", "`", "~", "!", "@", "#", "$", "%", "^",
			"&", "\\*", "-", "_", "=", "\\+" };
	private final static String[] specialSymbolZ = { "、", "、", "？", "·", "~", "！", "@", "#", "￥", "%", "……", "&", "\\*",
			"-", "——", "=", "\\+" };
	private final static String[] space = { " ", "\t", "\n", "\r","	","\\s*"," +","   "," "};

	private static List<String[]> specialChar = new ArrayList<>();
	static {
		specialChar.add(punctuation);
		specialChar.add(brackets);
		specialChar.add(specialSymbol);
		specialChar.add(specialSymbolZ);
	}

	public static String removeSpaceChar(String s) {
		s=s.trim();
		for (String sc : space) {
			s = s.replaceAll(sc, "");
		}
		return s.toLowerCase();
	}

	public static String removeAllChar(String s) {
		s=s.trim();
		for (String[] ss : specialChar) {
			for (String sc : ss) {
				s = s.replaceAll(sc, "");
			}
		}
		return removeSpaceChar(s);
	}
	

}
